package indi.luckly.common;

import indi.luckly.common.key.ErrorKey;
import lombok.Data;

@Data
public class ApiException extends Throwable {

    private String code;
    private String message;

    public static ApiException create(String code, String msg) {
        ApiException apiException = new ApiException();
        apiException.code = code;
        apiException.message = msg;
        return apiException;
    }

    public static ApiException create(ErrorKey errorKey) {
        ApiException apiException = new ApiException();
        apiException.code = errorKey.getValue() + "";
        apiException.message = errorKey.describe();
        return apiException;
    }




}
